<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<%@include file="/common/taglibs.jsp" %>
<%@include file="/common/javascript.jsp" %>
<html>
  <head>
    <base href="<%=basePath%>">
	<style type="text/css">	
		/*提交表单*/
		.l-table-edit {font-size:12px; color:#555; padding:5px 5px 5px 0px;}
		.l-table-edit-td{ padding:5px; padding-left:0;}
	</style>
	<script src="js/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript">
		var viewType='${viewType}';
		var landType='${land.landType}';
		var strPoints='${land.points}';
		var isSelectedMap=true;
		var strlng='${land.lng}';
		var strlat='${land.lat}';
		var markerName='${land.markerName}';
		$(function(){
			if(viewType=="detail"){
				$("form input").attr("readonly","readonly"); 
				$("form textarea").attr("readonly","readonly");
				$("form select").attr("disabled", "disabled"); 
			}
		
			$("#location").bind('click',function(){
		    	if(landType=='1'){//添加点状地块
		    		var url="mapAction_getLoc?viewType="+viewType+"&operateType=getloc&type=3"
		    			+"&landEntity.lng="+strlng+"&landEntity.lat="+strlat+"&markerName="+markerName;
					var title='获取地块坐标';
					window.parent.openMap(url,title);
		    	}else{
		    		var url="mapAction_getLoc?viewType="+viewType
		    			+"&operateType=getPolygon&type=3&landEntity.points="+strPoints
		    			+"&landEntity.lng="+strlng+"&landEntity.lat="+strlat;
					var title='获取地块坐标';
					window.parent.openMap(url,title);
		    	}
				
				$("#content").dialog('open');
			});
			
			if(viewType=="add"){
				landType='1';
				markerName="1.png";
				isSelectedMap=false;
			}
			
			$("#comlt").bind('change',function(){
				landType=$("#comlt").val();
			});
		});

		function setLonlat(e){
        	strlng=e.point.lng;
        	strlat=e.point.lat;
        	isSelectedMap=true;
        }
        
        function setArea(str,center){
        	strPoints=str;
        	strlng=center.lng;
        	strlat=center.lat;
        	isSelectedMap=true;
        }
		
		function saveInfo(){
			if(mainform.check()){
				if(!isSelectedMap){
					$.messager.alert('提示',"请先从地图上获取地块位置","info");
					return;
				}
				$("#mainform").form('submit',{
					url:'landAction_savePlanLand?lon='+strlng+'&lat='+strlat
						+'&land.points='+strPoints+'&land.markerName='+markerName,
					success: function(data){  
						var data = eval('(' + data + ')'); 
						if (!data.success){ //保存失败  
							$.messager.alert('提示',"错误"+data.message,"info");
        				}else{//保存成功
        					$.messager.alert('提示',data.message,"info",function(){
        						//调用父窗体的方法，关闭弹出框，并刷新网格
        						window.parent.closeContent();
        					});
        				} 
					}
				});
			}else{
				$.messager.alert('提示',"请先填写必要信息","info");
				return;
			}
		}
		function modifyMarker()
		{
			var url="mapAction_modifyMarker";
			var title='修改图标';
			window.parent.openMarker(url,title);
		}
		
		function setMarkerName(e){
			if(typeof(e) != "undefined"){
				markerName=e;
				$("#marker").attr('src','images/marker/'+e);
			}
		}
	</script>
  </head>
  
  <body>
	<form name="mainform" method="post"  id="mainform">
    	<table cellpadding="0" cellspacing="0" class="l-table-edit" style="width: 95%; margin-top:10px; margin-left:15px; column-gap:8px">
        	<tr>
            	<td align="right" class="l-table-edit-td"><label class="red">*</label>编号:</td>
                <td align="left" class="l-table-edit-td">
                	<c:if test="${viewType=='detail' }">
                		${ land.num }
                	</c:if>
                	<c:if test="${viewType!='detail' }">
                		<input name="land.num" id="num"  value="${ land.num}" datatype="*" altercss="gray" tip="请填写编号"/>
                	</c:if>
                	<input type="hidden" name="id" id="id" value="${land.id}">
                	<input type="hidden" name="land.type" value="2">
                	<input type="hidden" name="viewType" value="${viewType}">
                </td>
                
               <td align="right" class="l-table-edit-td"> <label class="red">*</label>名称:</td>
                <td align="left" class="l-table-edit-td">
                	<input type="text" name="land.name" value="${land.name}" datatype="*" altercss="gray" tip="请填写名称">
                </td>
            </tr>
            <tr>
            	<td align="right" class="l-table-edit-td"><label class="red">*</label> 创建时间:</td>
                <td align="left" class="l-table-edit-td">
                	<c:if test="${viewType=='add' }">
                		<input type="text" name="land.dateCre" class="Wdate" onclick="WdatePicker({skin:'whyGreen'})" value='<s:date name="land.dateCre"  format="yyyy-MM-dd"/>'>
                	</c:if>
                	<c:if test="${viewType!='add' }">
                		<s:date name="land.dateCre"  format="yyyy-MM-dd"/>
                	</c:if>
                </td>
                <td align="right" class="l-table-edit-td"><label class="red">*</label>地块类型:</td>
                <td align="left" class="l-table-edit-td">
                	<select name="land.landType" id="comlt" style="width:150px;">
                		<option value="1" <s:if test="land.landType==1"> selected </s:if>>点状地块</option>
                		<option value="2" <s:if test="land.landType==2"> selected </s:if>>块状地块</option>
                	</select>
                	<a id="location" class="easyui-linkbutton" data-options="plain:'false'" style="text-align:center">获取地块</a>
                	<c:if test="${viewType=='add' }">
                		<a class="easyui-linkbutton" data-options="plain:'false'" style="text-align:center">
                		<img id="marker" name="marker" style="height: 25px;" src="images/marker/1.png" onclick="modifyMarker()">
                		</a>
                	</c:if>
                	<c:if test="${viewType=='modify' && land.landType=='1' }">
                		<a class="easyui-linkbutton" data-options="plain:'false'" style="text-align:center">
                		<img id="marker" name="marker" style="height: 25px;" src="images/marker/${land.markerName}" onclick="modifyMarker()">
                		</a>
                	</c:if>
                </td>
            </tr> 
            
            <tr>
                <td align="right" class="l-table-edit-td"><label class="red">*</label>土地用途:</td>
                <td align="left" class="l-table-edit-td">
                	<select name="land.useType" style="width:150px;">
                	<s:iterator value="useTypes" >
                	 <option value='<s:property value="key" />' <s:if test="key==land.useType">selected </s:if>><s:property value="value"/><s:property value="#iType"/></option>
                	</s:iterator>
                	</select>
                </td>
                
                <td align="right" class="l-table-edit-td"><label class="red">*</label>出让面积:</td>
                <td align="left" class="l-table-edit-td">
                	<input type="text" name="land.sellArea" value="${land.sellArea }" datatype="d" altercss="gray" tip="请填写出让面积(数字)"> m&sup2; 
                </td>
            </tr>
             <tr>
            	<td align="right" class="l-table-edit-td"><label class="red">*</label>地块要点:</td>
                <td align="left" class="l-table-edit-td">
                	<input type="text" name="land.point" value="${land.point }" datatype="*" altercss="gray" tip="请填写地块要点">
                </td>
               
                <td align="right" class="l-table-edit-td"><label class="red">*</label>挂牌起始价格:</td>
                <td align="left" class="l-table-edit-td">
                	<input type="text" name="land.transPrice" value="${land.transPrice }" datatype="d" altercss="gray" tip="请填写起始价格（数字）">
                </td>
            </tr>
             <tr>
                <td align="right" class="l-table-edit-td"><label class="red">*</label>挂牌时间:</td>
                <td align="left" class="l-table-edit-td">
                	<input type="text" name="land.list_date" class="Wdate" onclick="WdatePicker({skin:'whyGreen'})" value='<s:date name="land.list_date" format="yyyy-MM-dd"/>'>
                </td>
            	 <td align="right" class="l-table-edit-td"><label class="red">*</label>区位:</td>
                <td align="left" class="l-table-edit-td">
                	<select name="land.region.id" style="width: 150px;"> 
                	<s:iterator value="areas"> 
                	 <option value='<s:property value="key"/>' <s:if test="key==land.region.id">selected </s:if>=""><s:property value="value" /></option> 
                	</s:iterator> 
                	</select>
                </td>
               
            </tr>
            <tr>
                <td align="right" class="l-table-edit-td"><label class="red">*</label>坐落:</td>
                <td align="left" class="l-table-edit-td">
                	<input type="text" name="land.location" value="${land.location}" datatype="*" altercss="gray" tip="请填写坐落位置">
                </td>
            </tr>
            <tr>
            	<td align="right" class="l-table-edit-td">备注:</td>
                <td align="left" class="l-table-edit-td" colspan="3">
                	<textarea name="land.remark" id="land.remark" rows="3" style="width: 100%;">${land.remark }</textarea>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>
